<?php
namespace app\erp\validate;

use think\Validate;

class Categoryrule extends Validate
{

    protected $rule = [
        'category_name' => 'require|unique:category,category_name^partner_id^site_id^parent_sign',
        'sort' => 'require|number',
        'site_rate' => 'number|between:1,100'
    ];

    protected $message = [
        'category_name.require' => '分类名称必须填写',
        'category_name.unique' => '分类名称已存在',
        'sort.require' => '排序不能为空',
        'sort.number' => '排序只能是数字',
        'site_rate.number' => '折扣率只能是数字',
        'site_rate.between' => '折扣率只能在：1-100之间'
    ];
    protected $scene = [
        'edit' => [
            'category_name' => 'unique:category,category_name^partner_id^site_id^parent_sign',
            'sort' => 'number',
            'site_rate' => 'number|between:1,100'
        ]
    ];
}